#include <stdio.h>

int main() {
    int n = 0;
    scanf("%d",&n);
    int arr1[n][n];
    int i = 0;
    for(i = 0; i < n; i++)
    {
        int j = 0;
        for(j = 0;j < n;j++)
        {
            scanf("%d ",&arr1[i][j]);
        }
    }
    int line = 0;
    int a = 1;
    for(line = 0;line < n-1; line++)
    {
        int row = 0;
        for(row = line +1; row < n; row ++)
        {
            if(arr1[row][line] != 0)
            {
                a = 0;
                goto flag;
            }
        }
    }
    flag:
        if (0 == a)
            printf("NO");
        else
            printf("YES");
    return 0;
}
